import routes from '../routes.js'
const wxrouter = {
  pushViewControllerParams(url){

    routes.push(url)
    // window.location.href = url;

  },
  popViewController(){

    routes.back()
    // window.location.href = url;

  },
  startEventQueryActivity(url){
    // window.location.href = "FangchanjuWap/page/event_search.html?from="+encodeURIComponent(window.location.origin+window.location.pathname);
    window.location.href = "Press_wap/page/search.html?from="+encodeURIComponent(window.location.origin+window.location.pathname);
  },
  writeCommentActivity(e){
    console.log(e);
    window.location.href = "Press_wap/page/comment.html?bookId="+e.bookID;
  },
  goWechatPay(e,orderId){
    var jsparam=JSON.stringify(e); 
    sessionStorage.setItem('jsparam',jsparam);
    window.location.href = "Press_wap/page/wechatPay.html?orderId="+orderId;
  }
}

// 定义user模块的元 (meta) 信息.
const meta = {
  wxrouter: [{
    name: 'pushViewControllerParams',
    args: ['string']
  },{
    name: 'popViewController',
    args: ['string']
  },
  {
    name: 'startEventQueryActivity',
    args: ['string']
  },
  {
    name: 'goWechatPay',
    args: ['string']
  }
  ]
}

export default {
  init (Weex) {
    // 注册这个模块，最后一个参数是模块的元信息.
    Weex.registerApiModule('wxrouter', wxrouter, meta)
    // console.log("注册中");
  }
}
